#include "stdafx.hpp"
#include "ColligereDatabaseEventBase.hpp"

DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_REQUEST )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_POST )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_COMMIT_START )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_COMMIT_END )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_ADD )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_CHANGE )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_DELETE )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_QUERIED )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_RESTORE )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_LIST_COMMIT_START )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_LIST_COMMIT_END )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_LIST_QUERY_ALL_START )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_ITEM_LIST_QUERY_ALL_END )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_USER_REQUEST_CLOSE )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_OPEN_END )
DEFINE_EVENT_TYPE ( COLLIGERE_EVT_DATABASE_OPEN_START )

IMPLEMENT_DYNAMIC_CLASS ( col::DatabaseEventBase, wxEvent )

col::DatabaseEventBase::DatabaseEventBase ( wxEventType commandType, 
										   wxInt32 id, const DatabaseItemBase *pItem ) 
										   : wxEvent ( id, commandType ), 
										   mVetoed ( false ), mpItem ( pItem )
{
	m_propagationLevel = wxEVENT_PROPAGATE_MAX;
}

col::DatabaseEventBase::DatabaseEventBase()
{
}

col::DatabaseEventBase::~DatabaseEventBase()
{
}

bool col::DatabaseEventBase::Vetoed() const
{
	return mVetoed;
}

void col::DatabaseEventBase::Veto ( bool veto )
{
	mVetoed = veto;
}

wxEvent *col::DatabaseEventBase::Clone() const
{ 
	return ( new DatabaseEventBase ( *this ) ); 
}

const col::DatabaseItemBase *col::DatabaseEventBase::GetItem() const
{
	return mpItem;
}

///////////////////////////////////////
// ColligereDatabaseRequestEvent
///////////////////////////////////////

IMPLEMENT_DYNAMIC_CLASS ( col::DatabaseRequestEvent, col::DatabaseEventBase )

col::DatabaseRequestEvent::DatabaseRequestEvent 
( DatabaseItemId itemId, DatabaseItemId itemParentId, 
 const wxString &rItemName, wxUint32 id ) : mItemId ( itemId ), 
mItemName ( rItemName ), mItemParentId ( itemParentId ), 
DatabaseEventBase ( COLLIGERE_EVT_DATABASE_ITEM_REQUEST, id )
{
}

col::DatabaseRequestEvent::DatabaseRequestEvent() : 
mItemId ( DatabaseItemBase::InvalidItemId ),
mItemParentId ( DatabaseItemBase::InvalidItemId )
{
}

col::DatabaseRequestEvent::~DatabaseRequestEvent()
{
}

wxEvent *col::DatabaseRequestEvent::Clone() const
{ 
	return ( new DatabaseRequestEvent ( *this ) ); 
}

wxUint32 col::DatabaseRequestEvent::GetItemId() const 
{ 
	return mItemId; 
}

wxUint32 col::DatabaseRequestEvent::GetItemParentId() const 
{ 
	return mItemParentId; 
}

const wxString &col::DatabaseRequestEvent::GetItemName() const 
{ 
	return mItemName; 
}